gdk: Maintain popup tree in the frontend
authorMatthias Clasen <mclasen@redhat.com>
Wed, 22 May 2019 22:04:45 +0000 (22:04 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 May 2019 20:25:17 +0000 (20:25 +0000)
We will need this information here, and we can
share the child lists between various backends.

gdk/broadway/gdksurface-broadway.c
gdk/broadway/gdksurface-broadway.h
gdk/gdksurface.c
gdk/gdksurfaceprivate.h
gdk/x11/gdksurface-x11.c
gdk/x11/gdksurface-x11.h

index 6c3af4c95aae87c6e366594055b041a57ad084fe..d8a0ffb44c65fad7b9a89bae5da9d6750a1796c0 100644 (file)
@@ -66,21 +66,13 @@ gdk_broadway_surface_init (GdkBroadwaySurface *impl)
 static void
 gdk_broadway_surface_finalize (GObject *object)
 {
-  GdkSurface *surface;
   GdkBroadwaySurface *impl;
   GdkBroadwayDisplay *broadway_display;
 
   g_return_if_fail (GDK_IS_BROADWAY_SURFACE (object));
 
-  surface = GDK_SURFACE (object);
   impl = GDK_BROADWAY_SURFACE (object);
 
-  if (surface->parent)
-    {
-      GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (surface->parent);
-      parent_impl->popups = g_list_remove (parent_impl->popups, surface);
-    }
-
   _gdk_broadway_surface_grab_check_destroy (GDK_SURFACE (impl));
 
   broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (GDK_SURFACE (impl)));
@@ -238,12 +230,6 @@ _gdk_broadway_display_create_surface (GdkDisplay     *display,
 
   connect_frame_clock (surface);
 
-  if (parent)
-    {
-      GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (parent);
-      parent_impl->popups = g_list_prepend (parent_impl->popups, surface);
-    }
-
   return surface;
 }
 
@@ -818,10 +804,9 @@ gdk_broadway_surface_set_functions (GdkSurface    *surface,
 void
 gdk_broadway_surface_update_popups (GdkSurface *parent)
 {
-  GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (parent);
   GList *l;
 
-  for (l = impl->popups; l; l = l->next)
+  for (l = parent ->children; l; l = l->next)
     {
       GdkBroadwaySurface *popup_impl = l->data;
       GdkSurface *popup = GDK_SURFACE (popup_impl);
index 4c47a887a635bab067d1578875a7bde22aac6a25..b2940f2b08143de9aedd8961a5473ebd91f2fcbd 100644 (file)
@@ -63,8 +63,6 @@ struct _GdkBroadwaySurface
 
   int offset_x;
   int offset_y;
-
-  GList *popups;
 };
 
 struct _GdkBroadwaySurfaceClass
index 281ac8b034461b93d071227895130e5d87276be7..7db9f2cc8dedc50a94e52c6a92b46b17941e3034 100644 (file)
@@ -90,7 +90,7 @@ enum {
 
 /* Global info */
 
-static void gdk_surface_finalize   (GObject              *object);
+static void gdk_surface_finalize     (GObject      *object);
 
 static void gdk_surface_set_property (GObject      *object,
                                       guint         prop_id,
@@ -633,6 +633,9 @@ gdk_surface_finalize (GObject *object)
   if (surface->opaque_region)
     cairo_region_destroy (surface->opaque_region);
 
+  if (surface->parent)
+    surface->parent->children = g_list_remove (surface->parent->children, surface);
+
   G_OBJECT_CLASS (gdk_surface_parent_class)->finalize (object);
 }
 
@@ -750,6 +753,10 @@ gdk_surface_new (GdkDisplay     *display,
                                         parent,
                                         x, y, width, height);
 
+  surface->parent = parent;
+  if (parent)
+    parent->children = g_list_prepend (parent->children, surface);
+
   g_signal_connect (display, "seat-removed",
                     G_CALLBACK (seat_removed_cb), surface);
 
index c7933fe0f25b080a6181bd0f68fd1e02187d064d..ce81b23a8441ab0093cd7abc19c2516979ee8571 100644 (file)
@@ -34,6 +34,7 @@ struct _GdkSurface
 
   GdkSurface *transient_for; /* for toplevels */
   GdkSurface *parent;        /* for popups */
+  GList *children;           /* popups */
 
   gpointer widget;
 
index dc12f44f0aa5730169387c4a62de2129afbd3d5b..afdb6c243b59d487b980ba29ed1d345ae4a917ef 100644 (file)
@@ -425,20 +425,12 @@ gdk_x11_surface_end_frame (GdkSurface *surface)
 static void
 gdk_x11_surface_finalize (GObject *object)
 {
-  GdkSurface *surface;
   GdkX11Surface *impl;
 
   g_return_if_fail (GDK_IS_X11_SURFACE (object));
 
-  surface = GDK_SURFACE (object);
   impl = GDK_X11_SURFACE (object);
 
-  if (surface->parent)
-    {
-      GdkX11Surface *parent_impl = GDK_X11_SURFACE (surface->parent);
-      parent_impl->popups = g_list_remove (parent_impl->popups, surface);
-    }
-
   if (impl->toplevel->in_frame)
     unhook_surface_changed (GDK_SURFACE (impl));
 
@@ -916,12 +908,6 @@ _gdk_x11_display_create_surface (GdkDisplay     *display,
 
   gdk_surface_freeze_updates (surface);
 
-  if (parent)
-    {
-      GdkX11Surface *parent_impl = GDK_X11_SURFACE (parent);
-      parent_impl->popups = g_list_prepend (parent_impl->popups, surface);
-    }
-
   return surface;
 }
 
@@ -1383,10 +1369,9 @@ static void gdk_x11_surface_restack_toplevel (GdkSurface *surface,
 void
 gdk_x11_surface_update_popups (GdkSurface *parent)
 {
-  GdkX11Surface *impl = GDK_X11_SURFACE (parent);
   GList *l;
 
-  for (l = impl->popups; l; l = l->next)
+  for (l = parent->children; l; l = l->next)
     {
       GdkX11Surface *popup_impl = l->data;
       GdkSurface *popup = GDK_SURFACE (popup_impl);
index c051d10d826597cdd97103baf3dafbdcf51d9dd9..6c6744a71d839c8a2d9600148b9f389ea7003e3d 100644 (file)
@@ -78,8 +78,6 @@ struct _GdkX11Surface
 
   int offset_x;
   int offset_y;
-
-  GList *popups;
 };
  
 struct _GdkX11SurfaceClass